package com.linb.pan.server.modules.file.vo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.linb.pan.server.modules.file.entity.BPanUserFile;
import com.linb.pan.web.serializer.IdEncryptSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

@ApiModel(value = "面包屑实体")
@Data
public class BreadcrumbVO implements Serializable {

    private static final long serialVersionUID = 7215511932514221906L;

    @ApiModelProperty(value = "文件id")
    @JsonSerialize(using = IdEncryptSerializer.class)
    private Long id;

    @ApiModelProperty(value = "父文件夹id")
    @JsonSerialize(using = IdEncryptSerializer.class)
    private Long parentId;

    @ApiModelProperty(value = "文件夹名称")
    private String name;

    /**
     * BPanUserFile -> BreadcrumbVO
     */
    public static BreadcrumbVO transfer(BPanUserFile file) {
        BreadcrumbVO vo = new BreadcrumbVO();
        if (file != null) {
            vo.setId(file.getFileId());
            vo.setParentId(file.getParentId());
            vo.setName(file.getFilename());
        }
        return vo;
    }

}
